﻿using System;

class Lines
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 7 Dec 2011 Morning
        uint[] array = new uint[8];
        for (int i = 0; i < 8; i++)     //нанасяне на числата в матрица
        {
            array[i] = uint.Parse(Console.ReadLine());
        }

        int[] lines = new int[8]; // втори масив с броя линии //array of number of lines with length x -> lines[x-1]

        for (int row = 0; row < 8; row++)
        {
            int horizontalLength = 0;
            int verticalLength = 0;
            for (int col = 0; col < 8; col++)
            {
                if (((array[row] >> col) & 1) == 1)  // returns true if bit on col position of row element is set, i.e. cell(row, col)
                {
                    horizontalLength++;  // increases the length of Horizontal Lines counter while the bit's sequence is set.
                }
                else// if horizontal line breaks
                {
                    if (horizontalLength > 0)
                    {
                        lines[horizontalLength - 1]++;  // if we have line with positive length counts it
                        horizontalLength = 0;
                    }
                }

                if (((array[col] >> row) & 1) == 1) // returns true if bit on row position of col element is set, i.e. cell(col, row)
                {
                    verticalLength++; // increases the length of Vertical Lines counter while the bit's sequence is set.
                }
                else // if vertical line breaks
                {
                    if (verticalLength > 1)
                    {
                        lines[verticalLength - 1]++;  // if we have line with positive length counts it
                        verticalLength = 0;   // also avoids duplicate counting of lines with length of 1
                    }
                }
            }

            if (horizontalLength > 0)
            {
                lines[horizontalLength - 1]++; // if we have a final horizontal line with positive length counts it
            }
            if (verticalLength > 1)
            {
                lines[verticalLength - 1]++; // if we have a final vertical line with positive length counts it
            }            
        }
        
        for (int i = 7; i >=0; i--)
        {
            if (lines[i] > 0)
            {
                Console.WriteLine(i + 1);
                Console.WriteLine(lines[i]);
                break;
            }
        }
    }
}

